package events;

import java.sql.SQLException;

import org.hibernate.HibernateException;
import org.hibernate.Session;

import util.HibernateUtil;

public class EventMgr {
	public static void main(String[] args) throws HibernateException, SQLException {
		System.out.println("into main");
		EventMgr eventmgr = new EventMgr();
		eventmgr.CreateAndStoreEvent("testTitle");
		HibernateUtil.getSessionFactory().close();
	}

	private void CreateAndStoreEvent(String title) throws HibernateException, SQLException {
		Event event = new Event();
		event.setTitle(title);
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.save(event);
		session.getTransaction().commit();
		session.connection().close();
	}
}
